//
//  IAPAngel.h
//  BBQ
//
//  Created by danal Luo on 10/26/12.
//
//

#import <Foundation/Foundation.h>
#import <StoreKit/StoreKit.h>

#define kNotificationPurchaseComplete @"NotificationPurchaseComplete"

@protocol IAPAngelDelegate;

@interface IAPAngel : NSObject <SKProductsRequestDelegate,SKPaymentTransactionObserver>{
    SKProductsRequest *_request;
    SKProduct *_product;
}
@property (assign, nonatomic) id<IAPAngelDelegate> delegate;
@property (nonatomic) BOOL purchasing;
@property (copy, nonatomic) NSString *verifyReceiptUrl;

+ (id)shared;

- (void)requestProduct:(NSString *)productIdentifier;
- (void)cancelRequest;
- (void)makePayment:(SKProduct *)product;
- (void)restore;
- (NSString *)receiptForProduct:(NSString *)productIdentifier;
- (BOOL)isPurchasedProduct:(NSString *)productId;
- (BOOL)verifyReceipt:(NSData*)receipt;
@end


@protocol IAPAngelDelegate <NSObject>
- (void)angelDidReceiveProducts:(NSArray *)products;
- (void)angelDidCompleteTransaction:(SKPaymentTransaction *)transaction successful:(BOOL)successful;
- (void)angelDidRestoreTransactions:(NSArray *)transactions;
- (void)angelRequestDidFailWithError:(NSError *)error;
- (void)angelPaymentQueue:(SKPaymentQueue *)paymentQueue restoreCompletedTransactionsFailedWithError:(NSError *)error;
@end